package FunctionDemo.demo2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class test {
    public static void main(String[] args){
        // ArrayList<String> list = new ArrayList<>();
        ArrayList<Integer> list1 = new ArrayList<>();
        // Collections.addAll(list,"张无忌,13","周弱智,32","照明,12","张强,13","张先的,43");
        // // list.stream().filter(new test()::stringJudge).forEach(s -> System.out.println(s));
        // // List<Student> lsit = list.stream().map(new Function<String,Student>() {
        // //     @Override
        // //     public Student apply(String s){
        // //         String[] str = s.split(",");
        // //         String name = str[0];
        // //         int age = Integer.parseInt(str[1]);
        // //         return new Student(age,name);
        // //     }
        // // }).collect(Collectors.toList());

        // // 引用构造方法
        // List<Student> lsit = list.stream().map(Student::new).collect(Collectors.toList());
        // lsit.forEach(s -> System.out.println(s.getName() + s.getAge()));
        // 类的构造方法
        // Collections.addAll(list, "aaa","bbb","ccc");
        // list.stream().map(String::toUpperCase).forEach(s -> System.out.println(s));
        Collections.addAll(list1, 1, 2, 3, 4, 5);
        // Integer[] arr = list1.stream().toArray(new IntFunction<Integer[]>() {
        //     @Override
        //     public Integer[] apply(int i){
        //         return new Integer[i];
        //     }
        // });
        // System.out.println(arr);
        // 引用数组构造方法
        Integer[] arr = list1.stream().toArray(Integer[]::new);
    }
    public boolean stringJudge(String s){
        return s.startsWith("张") && s.length() == 3;
    }
}
